#include "processBar.h"
#include <unistd.h>
#include <string.h>

char bar[BAR_SIZE]= {0};
const char load[] = {'|','/','-','\\'};

void processBar(int rate)
{  
  int load_len = strlen(load);
  memset(bar,'#',sizeof(char)*rate); 
  printf("\033[0m\033[1;33m[%-100s][%d%%][%c]\r\033[0m",bar,rate,load[rate%load_len]);
  fflush(stdout);
  
  if(rate == 100)
    printf("[%-100s][%d%%]        \n",bar,rate);
}

void initProcessBar()
{
  memset(bar,'\0',sizeof(bar));
}
